﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Indigo.Quibbler.Controls
{
    /// <summary>
    /// Interaction logic for ThumbnailViewer.xaml
    /// </summary>
    public partial class ThumbnailViewer : UserControl
    {
        List<WindowStructure> _curWindows = new List<WindowStructure>();

        public List<WindowStructure> CurrentWindows
        {
            get { return _curWindows; }
            set
            {
                _curWindows = value;
                _SetItems();
            }
        }

        public static readonly DependencyProperty CurrentWindowsProperty = DependencyProperty.Register("CurrentWindows", typeof(List<WindowStructure>), typeof(ThumbnailViewer));

        public ThumbnailViewer()
        {
            InitializeComponent();
        }

        private void _SetItems()
        {
            listBox.ItemsSource = CurrentWindows;

        }

        private static void OnImageChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            try
            {

                ThumbnailViewer viewer = (ThumbnailViewer)sender;
                viewer.listBox.ItemsSource = (List<BitmapSource>)e.NewValue;
            }
            catch (Exception ex)
            {

            }
        }

        private void _WindowThumbnailClick(object sender, MouseButtonEventArgs e)
        {
            Image control = (Image)sender;
            WindowStructure curWindow = (WindowStructure)control.DataContext;
            curWindow.QuibblerWindow.WindowState = WindowState.Normal;
            curWindow.QuibblerWindow.Show();
        }
    }

    public class WindowStructure
    {
        public BitmapSource ImageSource { get; set; }
        public Window QuibblerWindow { get; set; }
    }
}
